TIMTOWTDI
#!/usr/bin/perl
use strict; # https://perlmonks.org/?node_id=11159342
use warnings;
use List::Util qw( sum );
local $_ = join '', ;
s/(?:\[ 0, \S+(,.*\n)){2,}/...
I'm afraid that didn't work - your output (once I created a 'sub print_result', that is :) ) looked like this:
-1, 5, 1 ,
1, 5, 1 ,
3, 4, 1 ,
5, 1, 1 ,
[ -23, -64, 0...
The first rule for any problem like this is: define a signature such that elements which should be seen as the same have the same signature, then use a hash with signatures as keys to group things....
You're right - I didn't even think to specify this. There's no case in which the third value can be different among repeats, so it's not an issue.
As to the order of the triplets, it would be th...